Resource management subsystem that maintains fairness and order

ABSTRACT

One embodiment of the present disclosure sets forth an effective way to maintain fairness and order in the scheduling of common resource access requests related to replay operations. Specifically, a streaming multiprocessor (SM) includes a total order queue (TOQ) configured to schedule the access requests over one or more execution cycles. Access requests are allowed to make forward progress when needed common resources have been allocated to the request. Where multiple access requests require the same common resource, priority is given to the older access request. Access requests may be placed in a sleep state pending availability of certain common resources. Deadlock may be avoided by allowing an older access request to steal resources from a younger resource request. One advantage of the disclosed technique is that older common resource access requests are not repeatedly blocked from making forward progress by newer access requests.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention generally relates to computer architectures and,more specifically, to a resource management subsystem that maintainsfairness and order.

2. Description of the Related Art

A common practice in parallel processing systems is to design aprocessor that executes some number of threads simultaneously. Eachthread may execute in a separate execution pipeline within theprocessor. As execution proceeds in parallel, different threads mayrequest access a common resource, such as a shared memory, in a mannerthat may cause the threads to encounter a resource conflict. Forexample, multiple threads may execute a common resource accessoperation, such as a memory load instruction, where the multiple threadscannot simultaneously access the resource. In such a case, at least onethread is allowed to access the common resource and complete the commonresource access operation. The pipeline transfers a copy of the commonresource, such as one of the cache lines that some of the threads areaccessing, and those threads are able to complete the common resourceaccess operation. However, the other threads accessing the same commonresource are not allowed to complete the common resource accessoperation and remain unserviced. Thus, some threads are allowed tocomplete the common resource access operation, while other threads arenot. Absent a means to process multiple threads accessing a commonresource, the operation is not able to complete successfully.

One approach to servicing multiple threads accessing a common resourceis to allocate the resource to one or more threads until the commonresource has no additional available access ports. Remaining threadsaccessing the same resource are placed in a pending state awaitingavailability of the common resource. When the common resource has one ormore available access ports, the common resource is allocated to one ormore pending requests for servicing until all access ports have againbeen allocated. The process continues until all requests to the commonresource have been serviced.

One drawback of this approach is that new requests may continue toarrive and consume access ports to the common resource while pendingrequests awaiting the same common resource remain unserviced. Such anoccurrence, when newer requests accessing a common resource are servicedbefore pending requests, is called a “priority inversion.” Anotherdrawback of this approach is that a pending request may be selected forservicing when a common resource becomes available. However, due topipeline latency, another newer request may consume the common resourcebefore the pending request is able to complete the common resourceaccess operation. Yet another drawback of this approach is that arequest may require access to two common resources, A and B, where A isavailable but B is not. The request is placed in a pending state until Bbecomes available. When B becomes available, the pending request isscheduled for completion. However, due to pipeline latency, anothernewer request may consume the A before the pending request is able tocomplete the common resource access operation. When newer accessrequests are continually allocated resources before older existingaccess requests, the older access requests may not be able to makeforward progress and thus are not able to complete execution.

As the foregoing illustrates, what is needed in the art is a moreeffective way to service threads accessing a common resource.

SUMMARY OF THE INVENTION

One embodiment of the present invention sets forth acomputer-implemented method for scheduling common resource accessrequests. The method includes receiving a first request for a commonresource, determining that the common resource is not available forallocation to requests, and in response, delaying servicing the firstrequest. The method further includes, subsequent to delaying servicing,receiving a second request for the common resource, and, subsequent toreceiving the second request, determining that the common resource hasbecome available for allocation to requests. The method further includesmaking the common resource available to the first request, prior tomaking the common resource available to the second request.

Other embodiments of the present invention include, without limitation,a subsystem comprising a streaming multiprocessor (SM) configured toimplement one or more aspects of the disclosed methods as well as acomputing device configured to implement one or more aspects of thedisclosed methods.

One advantage of the disclosed technique is that older common resourceaccess requests are not repeatedly blocked from making forward progressby newer access requests. Priority inversions are avoided by allocatingthe common resource to an existing older access request in preference tothe new access request.

BRIEF DESCRIPTION OF THE DRAWINGS

So that the manner in which the above recited features of the presentinvention can be understood in detail, a more particular description ofthe invention, briefly summarized above, may be had by reference toembodiments, some of which are illustrated in the appended drawings. Itis to be noted, however, that the appended drawings illustrate onlytypical embodiments of this invention and are therefore not to beconsidered limiting of its scope, for the invention may admit to otherequally effective embodiments.

FIG. 1 is a block diagram illustrating a computer system configured toimplement one or more aspects of the present invention;

FIG. 2 is a block diagram of a parallel processing subsystem for thecomputer system of FIG. 1, according to one embodiment of the presentinvention;

FIG. 3A is a block diagram of the front end of FIG. 2, according to oneembodiment of the present invention;

FIG. 3B is a block diagram of a general processing cluster within one ofthe parallel processing units of FIG. 2, according to one embodiment ofthe present invention;

FIG. 3C is a block diagram of a portion of the streaming multiprocessorof FIG. 3B, according to one embodiment of the present invention;

FIG. 4 illustrates a subsystem within the SM of FIG. 3C configured toservice pending common resource access operations, according to oneembodiment of the present invention;

FIG. 5 illustrates a TOQ entry aging unit within the TOQ of FIG. 4,according to one embodiment of the present invention;

FIGS. 6A and 6B set forth a flow diagram of method steps for addingcommon resource access requests to a total order queue, according to oneembodiment of the present invention;

FIG. 7 is a flow diagram of method steps for updating the status of acommon resource, according to one embodiment of the present invention;

FIG. 8 is a flow diagram of method steps for allocating a commonresource to a TOQ entry associated with a common resource accessrequest, according to one embodiment of the present invention;

FIG. 9 is a flow diagram of method steps for selecting a common resourceaccess request in a total order queue (TOQ) for servicing, according toone embodiment of the present invention.

FIG. 10 is a flow diagram of method steps for aging TOQ entries in a TOQentry buffer, according to one embodiment of the present invention; and

FIG. 11 is a flow diagram of method steps for transitioning a TOQ entryassociated with a common resource access request from a sleep state toan active state, according to one embodiment of the present invention.

DETAILED DESCRIPTION

In the following description, numerous specific details are set forth toprovide a more thorough understanding of the present invention. However,it will be apparent to one of skill in the art that the presentinvention may be practiced without one or more of these specificdetails.

System Overview

FIG. 1 is a block diagram illustrating a computer system 100 configuredto implement one or more aspects of the present invention. Computersystem 100 includes a central processing unit (CPU) 102 and a systemmemory 104 communicating via an interconnection path that may include amemory bridge 105. Memory bridge 105, which may be, e.g., a Northbridgechip, is connected via a bus or other communication path 106 (e.g., aHyperTransport link) to an I/O (input/output) bridge 107. I/O bridge107, which may be, e.g., a Southbridge chip, receives user input fromone or more user input devices 108 (e.g., keyboard, mouse) and forwardsthe input to CPU 102 via communication path 106 and memory bridge 105. Aparallel processing subsystem 112 is coupled to memory bridge 105 via abus or second communication path 113 (e.g., a Peripheral ComponentInterconnect (PCI) Express, Accelerated Graphics Port, or HyperTransportlink); in one embodiment parallel processing subsystem 112 is a graphicssubsystem that delivers pixels to a display device 110 (e.g., aconventional cathode ray tube or liquid crystal display based monitor).A system disk 114 is also connected to I/O bridge 107. A switch 116provides connections between I/O bridge 107 and other components such asa network adapter 118 and various add-in cards 120 and 121. Othercomponents (not explicitly shown), including universal serial bus (USB)or other port connections, compact disc (CD) drives, digital video disc(DVD) drives, film recording devices, and the like, may also beconnected to I/O bridge 107. The various communication paths shown inFIG. 1, including the specifically named communication paths 106 and113, may be implemented using any suitable protocols, such as PCIExpress, AGP (Accelerated Graphics Port), HyperTransport, or any otherbus or point-to-point communication protocol(s), and connections betweendifferent devices may use different protocols as is known in the art.

In one embodiment, the parallel processing subsystem 112 incorporatescircuitry optimized for graphics and video processing, including, forexample, video output circuitry, and constitutes a graphics processingunit (GPU). In another embodiment, the parallel processing subsystem 112incorporates circuitry optimized for general purpose processing, whilepreserving the underlying computational architecture, described ingreater detail herein. In yet another embodiment, the parallelprocessing subsystem 112 may be integrated with one or more other systemelements in a single subsystem, such as joining the memory bridge 105,CPU 102, and I/O bridge 107 to form a system on chip (SoC).

It will be appreciated that the system shown herein is illustrative andthat variations and modifications are possible. The connection topology,including the number and arrangement of bridges, the number of CPUs 102,and the number of parallel processing subsystems 112, may be modified asdesired. For instance, in some embodiments, system memory 104 isconnected to CPU 102 directly rather than through a bridge, and otherdevices communicate with system memory 104 via memory bridge 105 and CPU102. In other alternative topologies, parallel processing subsystem 112is connected to I/O bridge 107 or directly to CPU 102, rather than tomemory bridge 105. In still other embodiments, I/O bridge 107 and memorybridge 105 might be integrated into a single chip instead of existing asone or more discrete devices. Large embodiments may include two or moreCPUs 102 and two or more parallel processing subsystems 112. Theparticular components shown herein are optional; for instance, anynumber of add-in cards or peripheral devices might be supported. In someembodiments, switch 116 is eliminated, and network adapter 118 andadd-in cards 120, 121 connect directly to I/O bridge 107.

FIG. 2 illustrates a parallel processing subsystem 112, according to oneembodiment of the present invention. As shown, parallel processingsubsystem 112 includes one or more parallel processing units (PPUs) 202,each of which is coupled to a local parallel processing (PP) memory 204.In general, a parallel processing subsystem includes a number U of PPUs,where U≧1. (Herein, multiple instances of like objects are denoted withreference numbers identifying the object and parenthetical numbersidentifying the instance where needed.) PPUs 202 and parallel processingmemories 204 may be implemented using one or more integrated circuitdevices, such as programmable processors, application specificintegrated circuits (ASICs), or memory devices, or in any othertechnically feasible fashion.

Referring again to FIG. 1 as well as FIG. 2, in some embodiments, someor all of PPUs 202 in parallel processing subsystem 112 are graphicsprocessors with rendering pipelines that can be configured to performvarious operations related to generating pixel data from graphics datasupplied by CPU 102 and/or system memory 104 via memory bridge 105 andthe second communication path 113, interacting with local parallelprocessing memory 204 (which can be used as graphics memory including,e.g., a conventional frame buffer) to store and update pixel data,delivering pixel data to display device 110, and the like. In someembodiments, parallel processing subsystem 112 may include one or morePPUs 202 that operate as graphics processors and one or more other PPUs202 that are used for general-purpose computations. The PPUs may beidentical or different, and each PPU may have a dedicated parallelprocessing memory device(s) or no dedicated parallel processing memorydevice(s). One or more PPUs 202 in parallel processing subsystem 112 mayoutput data to display device 110 or each PPU 202 in parallel processingsubsystem 112 may output data to one or more display devices 110.

In operation, CPU 102 is the master processor of computer system 100,controlling and coordinating operations of other system components. Inparticular, CPU 102 issues commands that control the operation of PPUs202. In some embodiments, CPU 102 writes a stream of commands for eachPPU 202 to a data structure (not explicitly shown in either FIG. 1 orFIG. 2) that may be located in system memory 104, parallel processingmemory 204, or another storage location accessible to both CPU 102 andPPU 202. A pointer to each data structure is written to a pushbuffer toinitiate processing of the stream of commands in the data structure. ThePPU 202 reads command streams from one or more pushbuffers and thenexecutes commands asynchronously relative to the operation of CPU 102.Execution priorities may be specified for each pushbuffer by anapplication program via the device driver 103 to control scheduling ofthe different pushbuffers.

Referring back now to FIG. 2 as well as FIG. 1, each PPU 202 includes anI/O (input/output) unit 205 that communicates with the rest of computersystem 100 via communication path 113, which connects to memory bridge105 (or, in one alternative embodiment, directly to CPU 102). Theconnection of PPU 202 to the rest of computer system 100 may also bevaried. In some embodiments, parallel processing subsystem 112 isimplemented as an add-in card that can be inserted into an expansionslot of computer system 100. In other embodiments, a PPU 202 can beintegrated on a single chip with a bus bridge, such as memory bridge 105or I/O bridge 107. In still other embodiments, some or all elements ofPPU 202 may be integrated on a single chip with CPU 102.

In one embodiment, communication path 113 is a PCI Express link, inwhich dedicated lanes are allocated to each PPU 202, as is known in theart. Other communication paths may also be used. An I/O unit 205generates packets (or other signals) for transmission on communicationpath 113 and also receives all incoming packets (or other signals) fromcommunication path 113, directing the incoming packets to appropriatecomponents of PPU 202. For example, commands related to processing tasksmay be directed to a host interface 206, while commands related tomemory operations (e.g., reading from or writing to parallel processingmemory 204) may be directed to a memory crossbar unit 210. Hostinterface 206 reads each pushbuffer and outputs the command streamstored in the pushbuffer to a front end 212.

Each PPU 202 advantageously implements a highly parallel processingarchitecture. As shown in detail, PPU 202(0) includes a processingcluster array 230 that includes a number C of general processingclusters (GPCs) 208, where C 1. Each GPC 208 is capable of executing alarge number (e.g., hundreds or thousands) of threads concurrently,where each thread is an instance of a program. In various applications,different GPCs 208 may be allocated for processing different types ofprograms or for performing different types of computations. Theallocation of GPCs 208 may vary dependent on the workload arising foreach type of program or computation.

GPCs 208 receive processing tasks to be executed from a workdistribution unit within a task/work unit 207. The work distributionunit receives pointers to processing tasks that are encoded as taskmetadata (TMD) and stored in memory. The pointers to TMDs are includedin the command stream that is stored as a pushbuffer and received by thefront end unit 212 from the host interface 206. Processing tasks thatmay be encoded as TMDs include indices of data to be processed, as wellas state parameters and commands defining how the data is to beprocessed (e.g., what program is to be executed). The task/work unit 207receives tasks from the front end 212 and ensures that GPCs 208 areconfigured to a valid state before the processing specified by each oneof the TMDs is initiated. A priority may be specified for each TMD thatis used to schedule execution of the processing task. Processing taskscan also be received from the processing cluster array 230. Optionally,the TMD can include a parameter that controls whether the TMD is addedto the head or the tail for a list of processing tasks (or list ofpointers to the processing tasks), thereby providing another level ofcontrol over priority.

Memory interface 214 includes a number D of partition units 215 that areeach directly coupled to a portion of parallel processing memory 204,where D 1. As shown, the number of partition units 215 generally equalsthe number of dynamic random access memory (DRAM) 220. In otherembodiments, the number of partition units 215 may not equal the numberof memory devices. Persons of ordinary skill in the art will appreciatethat DRAM 220 may be replaced with other suitable storage devices andcan be of generally conventional design. A detailed description istherefore omitted. Render targets, such as frame buffers or texture mapsmay be stored across DRAMs 220, allowing partition units 215 to writeportions of each render target in parallel to efficiently use theavailable bandwidth of parallel processing memory 204.

Any one of GPCs 208 may process data to be written to any of the DRAMs220 within parallel processing memory 204. Crossbar unit 210 isconfigured to route the output of each GPC 208 to the input of anypartition unit 215 or to another GPC 208 for further processing. GPCs208 communicate with memory interface 214 through crossbar unit 210 toread from or write to various external memory devices. In oneembodiment, crossbar unit 210 has a connection to memory interface 214to communicate with I/O unit 205, as well as a connection to localparallel processing memory 204, thereby enabling the processing coreswithin the different GPCs 208 to communicate with system memory 104 orother memory that is not local to PPU 202. In the embodiment shown inFIG. 2, crossbar unit 210 is directly connected with I/O unit 205.Crossbar unit 210 may use virtual channels to separate traffic streamsbetween the GPCs 208 and partition units 215.

Again, GPCs 208 can be programmed to execute processing tasks relatingto a wide variety of applications, including but not limited to, linearand nonlinear data transforms, filtering of video and/or audio data,modeling operations (e.g., applying laws of physics to determineposition, velocity and other attributes of objects), image renderingoperations (e.g., tessellation shader, vertex shader, geometry shader,and/or pixel shader programs), and so on. PPUs 202 may transfer datafrom system memory 104 and/or local parallel processing memories 204into internal (on-chip) memory, process the data, and write result databack to system memory 104 and/or local parallel processing memories 204,where such data can be accessed by other system components, includingCPU 102 or another parallel processing subsystem 112.

A PPU 202 may be provided with any amount of local parallel processingmemory 204, including no local memory, and may use local memory andsystem memory in any combination. For instance, a PPU 202 can be agraphics processor in a unified memory architecture (UMA) embodiment. Insuch embodiments, little or no dedicated graphics (parallel processing)memory would be provided, and PPU 202 would use system memoryexclusively or almost exclusively. In UMA embodiments, a PPU 202 may beintegrated into a bridge chip or processor chip or provided as adiscrete chip with a high-speed link (e.g., PCI Express) connecting thePPU 202 to system memory via a bridge chip or other communication means.

As noted above, any number of PPUs 202 can be included in a parallelprocessing subsystem 112. For instance, multiple PPUs 202 can beprovided on a single add-in card, or multiple add-in cards can beconnected to communication path 113, or one or more of PPUs 202 can beintegrated into a bridge chip. PPUs 202 in a multi-PPU system may beidentical to or different from one another. For instance, different PPUs202 might have different numbers of processing cores, different amountsof local parallel processing memory, and so on. Where multiple PPUs 202are present, those PPUs may be operated in parallel to process data at ahigher throughput than is possible with a single PPU 202. Systemsincorporating one or more PPUs 202 may be implemented in a variety ofconfigurations and form factors, including desktop, laptop, or handheldpersonal computers, servers, workstations, game consoles, embeddedsystems, and the like.

Multiple Concurrent Task Scheduling

Multiple processing tasks may be executed concurrently on the GPCs 208and a processing task may generate one or more “child” processing tasksduring execution. The task/work unit 207 receives the tasks anddynamically schedules the processing tasks and child processing tasksfor execution by the GPCs 208.

FIG. 3A is a block diagram of the task/work unit 207 of FIG. 2,according to one embodiment of the present invention. The task/work unit207 includes a task management unit 300 and the work distribution unit340. The task management unit 300 organizes tasks to be scheduled basedon execution priority levels. For each priority level, the taskmanagement unit 300 stores a list of pointers to the TMDs 322corresponding to the tasks in the scheduler table 321, where the listmay be implemented as a linked list. The TMDs 322 may be stored in thePP memory 204 or system memory 104. The rate at which the taskmanagement unit 300 accepts tasks and stores the tasks in the schedulertable 321 is decoupled from the rate at which the task management unit300 schedules tasks for execution. Therefore, the task management unit300 may collect several tasks before scheduling the tasks. The collectedtasks may then be scheduled based on priority information or using othertechniques, such as round-robin scheduling.

The work distribution unit 340 includes a task table 345 with slots thatmay each be occupied by the TMD 322 for a task that is being executed.The task management unit 300 may schedule tasks for execution when thereis a free slot in the task table 345. When there is not a free slot, ahigher priority task that does not occupy a slot may evict a lowerpriority task that does occupy a slot. When a task is evicted, the taskis stopped, and if execution of the task is not complete, then a pointerto the task is added to a list of task pointers to be scheduled so thatexecution of the task resumes at a later time. When a child processingtask is generated, during execution of a task, a pointer to the childtask is added to the list of task pointers to be scheduled. A child taskmay be generated by a TMD 322 executing in the processing cluster array230.

Unlike a task that is received by the task/work unit 207 from the frontend 212, child tasks are received from the processing cluster array 230.Child tasks are not inserted into pushbuffers or transmitted to thefront end. The CPU 102 is not notified when a child task is generated ordata for the child task is stored in memory. Another difference betweenthe tasks that are provided through pushbuffers and child tasks is thatthe tasks provided through the pushbuffers are defined by theapplication program whereas the child tasks are dynamically generatedduring execution of the tasks.

Task Processing Overview

FIG. 3B is a block diagram of a GPC 208 within one of the PPUs 202 ofFIG. 2, according to one embodiment of the present invention. Each GPC208 may be configured to execute a large number of threads in parallel,where the term “thread” refers to an instance of a particular programexecuting on a particular set of input data. In some embodiments,single-instruction, multiple-data (SIMD) instruction issue techniquesare used to support parallel execution of a large number of threadswithout providing multiple independent instruction units. In otherembodiments, single-instruction, multiple-thread (SIMT) techniques areused to support parallel execution of a large number of generallysynchronized threads, using a common instruction unit configured toissue instructions to a set of processing engines within each one of theGPCs 208. Unlike a SIMD execution regime, where all processing enginestypically execute identical instructions, SIMT execution allowsdifferent threads to more readily follow divergent execution pathsthrough a given thread program. Persons of ordinary skill in the artwill understand that a SIMD processing regime represents a functionalsubset of a SIMT processing regime.

Operation of GPC 208 is advantageously controlled via a pipeline manager305 that distributes processing tasks to streaming multiprocessors (SMs)310. Pipeline manager 305 may also be configured to control a workdistribution crossbar 330 by specifying destinations for processed dataoutput by SMs 310.

In one embodiment, each GPC 208 includes a number M of SMs 310, whereM≧1, each SM 310 configured to process one or more thread groups. Also,each SM 310 advantageously includes an identical set of functionalexecution units (e.g., execution units and load-store units—shown asExec units 302 and LSUs 303 in FIG. 3C) that may be pipelined, allowinga new instruction to be issued before a previous instruction hasfinished, as is known in the art. Any combination of functionalexecution units may be provided. In one embodiment, the functional unitssupport a variety of operations including integer and floating pointarithmetic (e.g., addition and multiplication), comparison operations,Boolean operations (AND, OR, XOR), bit-shifting, and computation ofvarious algebraic functions (e.g., planar interpolation, trigonometric,exponential, and logarithmic functions, etc.); and the same functionalunit hardware can be leveraged to perform different operations.

The series of instructions transmitted to a particular GPC 208constitutes a thread, as previously defined herein, and the collectionof a certain number of concurrently executing threads across theparallel processing engines (not shown) within an SM 310 is referred toherein as a “warp” or “thread group.” As used herein, a “thread group”refers to a group of threads concurrently executing the same program ondifferent input data, with one thread of the group being assigned to adifferent processing engine within an SM 310. A thread group may includefewer threads than the number of processing engines within the SM 310,in which case some processing engines are idle during cycles when thatthread group is being processed. A thread group may also include morethreads than the number of processing engines within the SM 310, inwhich case processing takes place over consecutive clock cycles. Sinceeach SM 310 can support up to G thread groups concurrently, it followsthat up to G*M thread groups can be executing in GPC 208 at any giventime.

Additionally, a plurality of related thread groups may be active (indifferent phases of execution) at the same time within an SM 310. Thiscollection of thread groups is referred to herein as a “cooperativethread array” (“CTA”) or “thread array.” The size of a particular CTA isequal to m*k, where k is the number of concurrently executing threads ina thread group and is typically an integer multiple of the number ofparallel processing engines within the SM 310, and m is the number ofthread groups simultaneously active within the SM 310. The size of a CTAis generally determined by the programmer and the amount of hardwareresources, such as memory or registers, available to the CTA.

Each SM 310 includes a level one (L1) cache (shown in FIG. 3C) or usesspace in a corresponding L1 cache outside of the SM 310 that is used toperform load and store operations. Each SM 310 also has access to leveltwo (L2) caches that are shared among all GPCs 208 and may be used totransfer data between threads. Finally, SMs 310 also have access tooff-chip “global” memory, which can include, e.g., parallel processingmemory 204 and/or system memory 104. It is to be understood that anymemory external to PPU 202 may be used as global memory. Additionally, alevel one-point-five (L1.5) cache 335 may be included within the GPC208, configured to receive and hold data fetched from memory via memoryinterface 214 requested by SM 310, including instructions, uniform data,and constant data, and provide the requested data to SM 310. Embodimentshaving multiple SMs 310 in GPC 208 beneficially share commoninstructions and data cached in L1.5 cache 335.

Each GPC 208 may include a memory management unit (MMU) 328 that isconfigured to map virtual addresses into physical addresses. In otherembodiments, MMU(s) 328 may reside within the memory interface 214. TheMMU 328 includes a set of page table entries (PTEs) used to map avirtual address to a physical address of a tile and optionally a cacheline index. The MMU 328 may include address translation lookasidebuffers (TLB) or caches which may reside within multiprocessor SM 310 orthe L1 cache or GPC 208. The physical address is processed to distributesurface data access locality to allow efficient request interleavingamong partition units 215. The cache line index may be used to determinewhether or not a request for a cache line is a hit or miss.

In graphics and computing applications, a GPC 208 may be configured suchthat each SM 310 is coupled to a texture unit 315 for performing texturemapping operations, e.g., determining texture sample positions, readingtexture data, and filtering the texture data. Texture data is read froman internal texture L1 cache (not shown) or in some embodiments from theL1 cache within SM 310 and is fetched from an L2 cache that is sharedbetween all GPCs 208, parallel processing memory 204, or system memory104, as needed. Each SM 310 outputs processed tasks to work distributioncrossbar 330 in order to provide the processed task to another GPC 208for further processing or to store the processed task in an L2 cache,parallel processing memory 204, or system memory 104 via crossbar unit210. A preROP (pre-raster operations) 325 is configured to receive datafrom SM 310, direct data to ROP units within partition units 215, andperform optimizations for color blending, organize pixel color data, andperform address translations.

It will be appreciated that the core architecture described herein isillustrative and that variations and modifications are possible. Anynumber of processing units, e.g., SMs 310 or texture units 315, preROPs325 may be included within a GPC 208. Further, as shown in FIG. 2, a PPU202 may include any number of GPCs 208 that are advantageouslyfunctionally similar to one another so that execution behavior does notdepend on which GPC 208 receives a particular processing task. Further,each GPC 208 advantageously operates independently of other GPCs 208using separate and distinct processing units, L1 caches to execute tasksfor one or more application programs.

Persons of ordinary skill in the art will understand that thearchitecture described in FIGS. 1, 2, 3A, and 3B in no way limits thescope of the present invention and that the techniques taught herein maybe implemented on any properly configured processing unit, including,without limitation, one or more CPUs, one or more multi-core CPUs, oneor more PPUs 202, one or more GPCs 208, one or more graphics or specialpurpose processing units, or the like, without departing the scope ofthe present invention.

In embodiments of the present invention, it is desirable to use PPU 202or other processor(s) of a computing system to execute general-purposecomputations using thread arrays. Each thread in the thread array isassigned a unique thread identifier (“thread ID”) that is accessible tothe thread during the thread's execution. The thread ID, which can bedefined as a one-dimensional or multi-dimensional numerical valuecontrols various aspects of the thread's processing behavior. Forinstance, a thread ID may be used to determine which portion of theinput data set a thread is to process and/or to determine which portionof an output data set a thread is to produce or write.

A sequence of per-thread instructions may include at least oneinstruction that defines a cooperative behavior between therepresentative thread and one or more other threads of the thread array.For example, the sequence of per-thread instructions might include aninstruction to suspend execution of operations for the representativethread at a particular point in the sequence until such time as one ormore of the other threads reach that particular point, an instructionfor the representative thread to store data in a shared memory to whichone or more of the other threads have access, an instruction for therepresentative thread to atomically read and update data stored in ashared memory to which one or more of the other threads have accessbased on their thread IDs, or the like. The CTA program can also includean instruction to compute an address in the shared memory from whichdata is to be read, with the address being a function of thread ID. Bydefining suitable functions and providing synchronization techniques,data can be written to a given location in shared memory by one threadof a CTA and read from that location by a different thread of the sameCTA in a predictable manner. Consequently, any desired pattern of datasharing among threads can be supported, and any thread in a CTA canshare data with any other thread in the same CTA. The extent, if any, ofdata sharing among threads of a CTA is determined by the CTA program;thus, it is to be understood that in a particular application that usesCTAs, the threads of a CTA might or might not actually share data witheach other, depending on the CTA program, and the terms “CTA” and“thread array” are used synonymously herein.

FIG. 3C is a block diagram of the SM 310 of FIG. 3B, according to oneembodiment of the present invention. The SM 310 includes an instructionL1 cache 370 that is configured to receive instructions and constantsfrom memory via L1.5 cache 335. A warp scheduler and instruction unit312 receives instructions and constants from the instruction L1 cache370 and controls local register file 304 and SM 310 functional unitsaccording to the instructions and constants. The SM 310 functional unitsinclude N exec (execution or processing) units 302 and P load-storeunits (LSU) 303.

SM 310 provides on-chip (internal) data storage with different levels ofaccessibility. Special registers (not shown) are readable but notwriteable by LSU 303 and are used to store parameters defining eachthread's “position.” In one embodiment, special registers include oneregister per thread (or per exec unit 302 within SM 310) that stores athread ID; each thread ID register is accessible only by a respectiveone of the exec unit 302. Special registers may also include additionalregisters, readable by all threads that execute the same processing taskrepresented by a TMD 322 (or by all LSUs 303) that store a CTAidentifier, the CTA dimensions, the dimensions of a grid to which theCTA belongs (or queue position if the TMD 322 encodes a queue taskinstead of a grid task), and an identifier of the TMD 322 to which theCTA is assigned.

If the TMD 322 is a grid TMD, execution of the TMD 322 causes a fixednumber of CTAs to be launched and executed to process the fixed amountof data stored in the queue 525. The number of CTAs is specified as theproduct of the grid width, height, and depth. The fixed amount of datamay be stored in the TMD 322 or the TMD 322 may store a pointer to thedata to be processed by the CTAs. The TMD 322 also stores a startingaddress of the program that is executed by the CTAs.

If the TMD 322 is a queue TMD, then a queue feature of the TMD 322 isused, meaning that the amount of data to be processed is not necessarilyfixed. Queue entries store data for processing by the CTAs assigned tothe TMD 322. The queue entries may also represent a child task that isgenerated by another TMD 322 during execution of a thread, therebyproviding nested parallelism. Typically, execution of the thread, or CTAthat includes the thread, is suspended until execution of the child taskcompletes. The queue may be stored in the TMD 322 or separately from theTMD 322, in which case the TMD 322 stores a queue pointer to the queue.Advantageously, data generated by the child task may be written to thequeue while the TMD 322 representing the child task is executing. Thequeue may be implemented as a circular queue so that the total amount ofdata is not limited to the size of the queue.

CTAs that belong to a grid have implicit grid width, height, and depthparameters indicating the position of the respective CTA within thegrid. Special registers are written during initialization in response tocommands received via front end 212 from device driver 103 and do notchange during execution of a processing task. The front end 212schedules each processing task for execution. Each CTA is associatedwith a specific TMD 322 for concurrent execution of one or more tasks.Additionally, a single GPC 208 may execute multiple tasks concurrently.

A parameter memory (not shown) stores runtime parameters (constants)that can be read but not written by any thread within the same CTA (orany LSU 303). In one embodiment, device driver 103 provides parametersto the parameter memory before directing SM 310 to begin execution of atask that uses these parameters. Any thread within any CTA (or any execunit 302 within SM 310) can access global memory through a memoryinterface 214. Portions of global memory may be stored in the L1 cache320.

Local register file 304 is used by each thread as scratch space; eachregister is allocated for the exclusive use of one thread, and data inany of local register file 304 is accessible only to the thread to whichthe register is allocated. Local register file 304 can be implemented asa register file that is physically or logically divided into P lanes,each having some number of entries (where each entry might store, e.g.,a 32-bit word). One lane is assigned to each of the N exec units 302 andP load-store units LSU 303, and corresponding entries in different lanescan be populated with data for different threads executing the sameprogram to facilitate SIMD execution. Different portions of the lanescan be allocated to different ones of the G concurrent thread groups, sothat a given entry in the local register file 304 is accessible only toa particular thread. In one embodiment, certain entries within the localregister file 304 are reserved for storing thread identifiers,implementing one of the special registers. Additionally, a uniform L1cache 375 stores uniform or constant values for each lane of the N execunits 302 and P load-store units LSU 303.

Shared memory 306 is accessible to threads within a single CTA; in otherwords, any location in shared memory 306 is accessible to any threadwithin the same CTA (or to any processing engine within SM 310). Sharedmemory 306 can be implemented as a shared register file or sharedon-chip cache memory with an interconnect that allows any processingengine to read from or write to any location in the shared memory. Inother embodiments, shared state space might map onto a per-CTA region ofoff-chip memory, and be cached in L1 cache 320. The parameter memory canbe implemented as a designated section within the same shared registerfile or shared cache memory that implements shared memory 306, or as aseparate shared register file or on-chip cache memory to which the LSUs303 have read-only access. In one embodiment, the area that implementsthe parameter memory is also used to store the CTA ID and task ID, aswell as CTA and grid dimensions or queue position, implementing portionsof the special registers. Each LSU 303 in SM 310 is coupled to a unifiedaddress mapping unit 352 that converts an address provided for load andstore instructions that are specified in a unified memory space into anaddress in each distinct memory space. Consequently, an instruction maybe used to access any of the local, shared, or global memory spaces byspecifying an address in the unified memory space.

The L1 cache 320 in each SM 310 can be used to cache private per-threadlocal data and also per-application global data. In some embodiments,the per-CTA shared data may be cached in the L1 cache 320. The LSUs 303are coupled to the shared memory 306 and the L1 cache 320 via a memoryand cache interconnect 380.

Total Order Queue that Maintains Fairness and Order

FIG. 4 illustrates a subsystem 400 within the SM 310 of FIG. 3Cconfigured to service pending common resource access operations,according to one embodiment of the present invention. As shown, thesubsystem 400 includes SM partitions 410, address generation units(AGUs) 420, an address multiplexer 440, a write data multiplexer 450, anarbitration unit 455, an L1 cache memory 460, a read data demultiplexer465, and a total order queue (TOQ) 430.

The SM partitions are located within the warp scheduler and instructionunit 312 of the SM 310. The SM partitions schedule and dispatch commonresource access requests to the LSUs 303. As shown, the SM partitions410 include a scheduler 412, a dispatch unit 414, and a replayinstruction buffer (RIB) 416. The scheduler 412 receives newinstructions from the instruction L1 cache 370 and schedules theinstructions for execution by the SM 310. The scheduler 412 submitsscheduled instructions to the dispatch unit 414.

The dispatch unit 414 receives schedule instructions from the scheduler412, and forwards the instructions to the appropriate functional unitwithin the SM 310 for execution. Where an instruction includes a commonresource access request, such as a request to load or store data inmemory, the dispatch unit forwards the instruction to an LSU 303. Beforedispatching such an instruction to the LSU 303, the dispatch unitdetermines whether there is an available entry in the RIB 416 toallocate to the instruction. An RIB entry is created for any commonresource access request that may need at least one replay operationduring the execution of the request. If there is an available RIB entry,then the dispatch unit stores information related to the instruction inthe RIB 416 and dispatches the instruction to the LSU 303. If there isno available RIB entry, then the dispatch unit 414 stalls the stream ofpending instructions directed to the LSU 303 until a RIB entry becomesavailable. In such a case, replay operations for dispatched instructionsare still allowed to execute to completion. Once an instruction hascompleted execution, the corresponding RIB entry is retired, and theretired RIB entry is available to the dispatch unit 414 to allocate to anew instruction. As further described below, the dispatch unit 414receives replay operation requests and requests to retire RIB entriesfrom the TOQ 430. In addition, the dispatch unit 414 sends write data tothe write data multiplexer 450, and receives read data from the readdata demultiplexer 465.

The RIB 416 stores information regarding instructions that include acommon resource access request. Such a request may require one or morereplay operations in order to complete execution. A common resourceaccess request may be able to complete in one execution cycle of the LSU303. However, under some conditions, the access request may not be ableto complete execution, and one or more additional execution cycles,called replay operations, are created in order for the access request tocomplete. These conditions include, without limitation, access requestsspanning more cache lines than be simultaneously access by the LSU 303,accesses to more locations within a structure than can be simultaneouslyserviced by the structure, accesses to a structure that is currentlyconsumed by prior requests, or access request that are lower in prioritythan another pending request. Information related to each such accessrequest is stored in an associated RIB entry. The RIB entry is retrievedduring subsequent replay operations and delivered to the LSU 303 tofacilitate execution of the replay operation. The RIB entry may include,without limitation, the instruction, constant values needed by theoperation, and the contents of registers needed by the operation. Itshould be recognized that the optimal number of available RIB entriesmay be based on a number of factors, including, without limitation, thefrequency of occurrence of conditions requiring a replay operation, theaverage number of replay operations created for an access request, andlatency within the dispatch unit 414. The RIB 416 sends commands andaddress locations to the AGU 420.

The AGUs 420, located within the LSU 303. Each AGU 420 is associatedwith a corresponding SM partition 410. For example, AGU 420(0) isassociated with SM partitions 410(0), and AGU 420(N) is associated withSM partitions 410(N). The AGU 420 receives commands and addresses alongsignal path 470 from the RIB 416. In response, the AGU 420 sends AGUrequest status to the TOQ 430 along signal path 472. In turn, the TOQ430 reads the AGU request status in order to determine whetheradditional replay operations are needed for the current access requestor whether the RIB entry corresponding to the current access request maybe retired. In addition, the AGU 420 sends address information to theaddress multiplexer 440 along signal path 474.

The address multiplexer 440 selects an address from the AGU 420corresponding to the current access request and sends the selectedaddress to the L1 cache 320. Each AGU 420 generates an address for thecurrent access request, as described above. The address multiplexer 440receives an address from each of the AGUs 420 along signal path 474. Theaddress multiplexer 440 also receives a control signal (not shown)identifying which AGU 420 is selected for the current access request. Ifthe control signal identifies AGU 420(0), then the address multiplexer440 sends the address generated by AGU 420(0) to the L1 cache 320. Ifthe control signal identifies AGU 420(N), then the address multiplexer440 sends the address generated by AGU 420(N) to the L1 cache 320.

When the common resource access request is a request to store data tothe common resource, the write data multiplexer 450 selects write datafrom the dispatch unit 414 corresponding to the current access requestand sends the selected write data to the L1 cache 320. Each dispatchunit within the SM partitions 410 generates write data for the currentaccess request, when the current access request is a store operation.The write data multiplexer 450 receives write data from each of thedispatch units 414 along signal path 476. The write data multiplexer 450also receives a control signal (not shown) identifying which SMpartition 410 is selected for the current store access request. If thecontrol signal identifies SM partition 410(0), then the write datamultiplexer 450 sends the write data generated by SM partition 410(0) tothe L1 cache 320. If the control signal identifies SM partition 410(N),then the write data multiplexer 450 sends the write data generated by SMpartition 410(N) to the L1 cache 320.

The arbitration unit 455 receives common resource access requests fromSM partitions 410 and other clients and sends a selected access requestto the common resource, such as the L1 cache memory 460, for servicing.The arbitration receives the address selected by the address multiplexer440 as well as addresses from other clients requesting access to thecommon resource. The arbitration unit 455 routes the address associatedwith the selected access request to the L1 cache memory 460. Likewise,for access requests to store data in memory, the arbitration unit 455routes the write data associated with the selected access request to theL1 cache memory 460. In addition, the arbitration unit 455 sendsarbitration status information to the TOQ 430 along signal path 478.

The L1 cache memory 460, located within the L1 cache 320, is exemplaryof a common resource accessible to SM partitions 410 and other externalclients. The L1 cache memory 460 includes memory locations accessible tocommon resource access requests in order to store or load data. The L1cache memory 460 receives addresses and control signals from thearbitration unit 455. The L1 cache memory 460 receives write dataassociated with store access requests from the arbitration unit 455, andsends read data associated with load access requests to the read datademultiplexer 465. As further described below, the L1 cache memory 460sends status associated with L1 cache requests to the TOQ 430 alongsignal path 482 and resource status along path 484. The L1 cache memory460 receives reservation counts from the TOQ 430 along signal path 486.

When the common resource access request is a request to load data fromthe common resource, the read data multiplexer 465 sends read data fromthe L1 cache memory 460 to the client requesting the load accessrequest. The requesting unit may be an SM partition 410 or another L1cache client. The read data multiplexer 465 receives a control signal(not shown) identifying which SM partition 410 is selected for thecurrent load access request. If the control signal identifies SMpartition 410(0), then the read data multiplexer 465 sends the read datagenerated by the L1 cache memory 460 to SM partition 410(0). If thecontrol signal identifies SM partition 410(N), then the read datamultiplexer 465 sends the read data generated by the L1 cache memory 460to SM partition 410(N) along signal path 480.

As further described in conjunction with FIG. 9, the TOQ 430 isconfigured to select a replay operation for execution based on theoldest access request that is not blocked waiting for a common resource,in a manner that is fair and avoids priority inversion. As shown, theTOQ 430 includes a TOQ entry buffer 432, configured to store TOQ entriescorresponding to each RIB entry within the SM partitions 410. As furtherdescribed in conjunction with FIGS. 6A-6B, the TOQ 430 creates a TOQentry within the TOQ entry buffer 432 when a new access request isreceived and retires the TOQ entry on completion of the access request.The size of the TOQ entry buffer 432 is based on the number of SMpartitions 410 and the number of RIB entries in each RIB 416. Forexample, where an SM 310 includes ‘P’ SM partitions 410, and each SMpartition 410 includes a RIB 416 comprising ‘B’ RIB entries, the TOQentry buffer 432 could include P X B RIB entries. As such, each TOQentry is paired with a corresponding entry in a RIB 416.

Each TOQ entry within the TOQ entry buffer 432 includes multiple fields,including, without limitation, the age of the associated access request,the identity of the SM partition 410 or other client that initiated theaccess request, the identity of the RIB that includes the replayoperation information, the common resources associated with the accessrequest and the status of the resources, wake-up conditions associatedwith the access request. The age of an access request may be explicitlyrecorded using well-known techniques such as via a priority scheme,least-recently-used, or least-recently-allocated approaches. As furtherdescribed in conjunction with FIG. 10, age may be implied by arrivaltime and position of the common resource access request within a storagequeue such as the TOQ entry buffer 432, as described in conjunction withFIGS. 4-5. Alternatively, age may be implied by arrival time andposition of a replay operation associated with the common resourceaccess request within a storage queue such as the TOQ entry buffer 432.

The status of a common resource may be described with respect to theaccess request associated with the TOQ entry. As further described inconjunction with FIG. 8, a common resource may be allocated to an accessrequest by updating the status of the common resource as recorded in thecorresponding TOQ entry. For example, the status of a common resourcemay indicate that the common resource is not needed by the accessrequest. In another example, the common resource may be needed by theaccess request, but has already been allocated to the access request. Inanother example, the common resource may be needed by the accessrequest, but has not yet been allocated to the access request. Inanother example, the common resource may be divided into portions, suchas cache lines, where a set, represented as a group of one or more cachelines, or a way, represented as a particular cache line within a givenset, is currently in use. In yet another example, the resource may belocked and the set or way are in use. As further described inconjunction with FIG. 7, the common resource status fields of the TOQentries may be routinely updated as the status conditions of the commonresources change.

Where needed resources are not yet allocated, locked, or in use, the TOQ430 determines whether the resource shortage is a short term ortransitory condition versus a long term condition. Access requests withshort-term or transitory resource conflicts may be eligible forimmediate execution or execution after a finite delay. Access requestswith a long term or indeterminate resource shortage may be placed into asleep state. As further described in conjunction with FIG. 11, the TOQ430 may wake up sleeping access requests on the occurrence of certainwake-up conditions. The TOQ entry corresponding to an access request ina sleep state may specify one or more of these wake-up conditions, suchas: the resource is available for allocation, the resource has beenunlocked, or the needed set or way of a cache-type resource is no longerin use.

TOQ entries that are sleeping are waiting for one or more wake-upconditions. Upon the occurrence of a wake-up condition, the TOQ 430 mayselect a single sleeping TOQ entry for wake-up or may broadcast awake-up operation to multiple sleeping entries. For example, where theresource is a first-in first-out memory (FIFO) that is configured todeliver one data value at a time, the TOQ 430 could wake up a single TOQentry that is waiting for the FIFO to be available. In another example,the TOQ 430 could broadcast a wake-up operation to multiple TOQ entrieswaiting for the same cache line to be filled with data. In such a case,the cache line is a resource than can satisfy all TOQ entries put tosleep while waiting for the cache line to be available. In some cases, aTOQ entry may exist for which no wake-up conditions are needed. Such aTOQ entry is eligible to be chosen for replay operation immediately, andis appropriate if the condition causing the common resource conflict isof a transitory or short term nature.

In one embodiment, during each execution cycle, the TOQ 430 selects theoldest eligible access request for one or more replay operations. Aneligible access request is one that has been allocated all neededresources and has satisfied all wake-up conditions. Access requests inthe sleep state are not eligible for selection. The TOQ 430 requestsreplay operations for an eligible TOQ entry based on the total replayoperation beats discovered for that entry, the number of requestedprescheduled replay operations, and the number of requested on-demandreplay operations. A beat comprises one or more replay operationsassociated with a particular common resource access request.

When a common resource access request is originally dispatched forexecution, and assuming the request is not pre-empted by the SM 310 orthe arbitration unit 455, the replay operation counter (not shown) isset to zero, and the total beats discovered counter (not shown) isinitialized according to the request status received from the AGUs 420and the L1 cache memory 460. If the access request includespre-scheduled replay operations, then the TOQ 430 accumulates beatsassociated with the pre-scheduled replay operations. The TOQ 430 thenaccumulates beats associated with on-demand replay operations, if theaccess request did not complete as a result of the pre-scheduled replayoperations.

It should be recognized that the TOQ 430 may be susceptible to deadlockor livelock conditions. A deadlock occurs, for example, if each of twoaccess requests requires two common resources, each access request isallocated one of the two resources, and each access request is placed ina sleep condition waiting for the other resource to become available. Insuch a case, neither access request would be able to acquire theadditional resource, and the access requests could perpetually remain ina sleep state. In another example, a sleeping access request could beplaced in an awake state when a needed resource becomes available, andthe resource could be assigned to a second access request. However, thesecond access request could be waiting for another resource, andtherefore would be placed back into a sleep state. Other access requestsawaiting the common resource could likewise be placed in an awake state,be allocated a port associated with the common resource, and placed backinto a sleep state. This process could continue until all ports of thecommon resource are consumed by sleeping requests, and the commonresource is not available to any active access requests.

Deadlock conditions may be particularly pronounced when one or moreaccess requests need the same common resource, and all access ports tothe common resource have been allocated to other requests. Such a commonresource may be called a scarce resource. In one embodiment, the TOQ 430may have a mechanism to manage resources when they are in scarce supply.When a common resource is deemed to be a scarce resource, priorityaccess to the scarce resource may be given to existing older TOQ entriesand any associated prescheduled replay operations rather than youngerTOQ entries associated with recently dispatched access requests. In atleast one embodiment, a common resource may be considered to be a scarceresource if at least one access request is currently in a sleep statewaiting for the resource to become available. Examples of resources thatmay become scarce include, without limitation, a first-in-first-out(FIFO) memory, a specific set and way in a cache-type memory, or any wayin a particular set of a cache-type memory. The TOQ 430 may not sendbroadcast wake-up operations once a common resource is determined to bea scarce resource. When a resource is considered to be scarce, the TOQ430 may assign the resource to an individual access request using asingle wake-up operation, rather than a broadcast wake-up operation. TheTOQ 430 may use the age of the TOQ entry, where the age may be theposition of the TOQ entry within the TOQ entry buffer 432, to allocatethe scarce resource to a sleeping TOQ entry. Once the assigned accessrequest completes execution, the scarce resource may become available,and may be assigned to another access request. Once a common resource isno longer considered to be scarce, that is, no sleeping access requestsare waiting for the resource, the TOQ 430 may resume sending broadcastwake-up operations associated with the resource.

Under certain conditions, deadlock conditions may be resolved byallowing a common resource needed by an older TOQ entry, and currentlyallocated to a younger TOQ entry, to be “stolen” from the younger TOQentry. If both TOQ entries need multiple resources, then neither entrymay be allocated all of the needed resources. In one example, the set ofcommon resources needed by an access request may change over time asvarious conditions are evolve throughout the execution cycle of theaccess request. An older TOQ entry could require two resources,identified as A and B, where only B is allocated to the access request.The older TOQ entry would be placed into a sleep state waiting forresource A. While the older TOQ entry is in the sleep state, a youngerTOQ entry could require common resources B and C, but only resource C isallocated. The younger resource could be placed in a sleep stateawaiting resource B. Once awake, the older TOQ entry could discoversthat the TOQ entry now requires resource C, currently allocated to theyounger TOQ entry. Both the older TOQ entry and the younger TOQ areawaiting allocation of a common resource allocated to the other TOQentry. One approach to resolve this type of deadlock condition is toallow the older TOQ entry to “steal” the needed common resources from ayounger TOQ entry.

In one embodiment, the TOQ 430 may employ virtual stealing, where theolder TOQ entry may be selected for one or more replay operations eventhough not all needed resources have been allocated. During execution ofthe replay operations, the associated access request may consumeresources reserved for younger entries. The resource reservations maynot be bound to the younger TOQ entries, so the older entry may be ableto gather all of the needed resources to make forward progress. Once theolder TOQ entry makes forward progress, the associated access requestmay free up needed resources, thereby allowing the common resources tobe allocated to younger TOQ entries.

In another embodiment, the TOQ 430 may employ physical stealing, where aspecific resource may be stolen from a specific TOQ entry and allocatedto an older TOQ entry requiring that resource. In such a case, thestatus of resources needed by the younger TOQ entry or entries may bemodified from an allocated status to a non-allocated status, and thestatus of the resources may be transitioned to an allocated state forthe older TOQ entry. Once the older TOQ entry makes sufficient progress,the associated request frees up the allocated resources, therebyallowing younger TOQ entries to acquire the needed resources.

In various embodiments, resource stealing may be triggered immediatelyupon discovering a resource conflict, or resource stealing may bedelayed for a fixed or variable period of time after the conflict isdiscovered. Resource stealing may be restricted to the oldest TOQ entry,where the oldest TOQ entry steals all needed, unallocated resources. Insuch a case, all other access requests that could potentially consumeresources needed by the oldest TOQ entry are deferred until at leastsome forward progress is made on the oldest TOQ entry.

Various configurations of common resources may be contemplated withinthe scope of the present invention. In one embodiment, some accessrequests managed by the TOQ 430 may have multiple processing phases,where the resources that are likely to be needed by each phase can vary.In one example, an access request includes threads that could belong todifferent address spaces, where one address space could be satisfied bya cache level portion of a more general memory hierarchy, and anotheraddress space could be satisfied by a self-contained local memory notincluded in the general memory hierarchy. In another embodiment, anaccess request may select a sequence of operands in adjacent memorylocations, where a different sequence of operands could be accessed foreach thread.

FIG. 5 illustrates a TOQ entry aging unit 500 within the TOQ 430 of FIG.4, according to one embodiment of the present invention. As shown, theTOQ entry aging unit 500 includes a request status distribution unit510, a resource status distribution unit 520, a TOQ entry buffer 432, areserved entry counter 550, and a priority selector 560.

The request status distribution unit 510 distributes status regardingcommon resource access requests to the TOQ entry buffer 432. The requeststatus distribution unit 510 receives address generation unit requeststatus from the AGU 420 along signal path 472, arbitration status fromthe arbitration unit 455 along signal path 478, and L1 cache requeststatus from the L1 cache memory 460 along signal path 482. The requeststatus distribution unit 510 then sends the request status informationfrom these three units to each TOQ entry cell 540 in the TOQ entrybuffer 432. The status information, in turn, is stored in an appropriatelocation within each TOQ entry cell 540.

The resource status distribution unit 520 distributes status regardingcommon resources to the TOQ entry buffer 432. The resource statusdistribution unit 520 receives L1 cache resource status from the L1cache memory 460 along signal path 484. The resource status distributionunit 520 then sends the resource status information to each TOQ entrycell 540 in the TOQ entry buffer 432. The status information, in turn,is stored in an appropriate location within each TOQ entry cell 540.

The TOQ entry buffer 432 includes a TOQ entry cell 540 for every entryin the RIB 416 within each SM partition 410. The TOQ entry buffer 432creates TOQ entries associated with new access requests received from SMpartitions 410 on the left side of the figure. The TOQ entry buffer 432shifts the TOQ entry cells 540 to the right as the TOQ entries age. Asshown, the TOQ entry buffer 432 includes TOQ entry cells 540 and TOQmultiplexers 530.

TOQ multiplexers 530 select whether a TOQ entry cell 540 recirculatesthe current state of the TOQ entry buffer 432, or shifts TOQ entry cells540 to the right as new access requests are received from the SMpartitions 410. To recirculate TOQ entry cells 540, the TOQ multiplexers530 select the recirculation path along signal paths exemplified by 580584 588. To shift TOQ entry cells 540, the TOQ multiplexers 530 selectthe shift path along signal paths exemplified by 582 586 590.

The TOQ entry cells 540 are configured to store information related tocommon resource access requests received from SM partitions. The TOQentry cells 540 are updated with changes to request status and resourcestatus from the request status distribution unit 510 and the resourcestatus distribution unit 520 respectively. Initially, the TOQ entrycells 540 and associated TOQ multiplexers 530 are configured torecirculate. The current state of TOQ entry cell [0] recirculates alongsignal path 580, the current state of TOQ entry cell [1] recirculatesalong signal path 584, and the current state of TOQ entry cell [2]recirculates along signal path 588. When a new access request isreceived from the SM partitions, TOQ entry cell [0] is configured toreceive and store a TOQ entry associated with the new access requestalong signal path 582. If the current state of TOQ entry cell [0]indicates an invalid TOQ entry, then the remaining TOQ entry cells 540recirculate. If, however, TOQ entry cell [0] is marked as a valid TOQentry, then the TOQ entry is shifted to the next TOQ entry cell 540. Insuch a case, TOQ entry cell [1] receives the TOQ entry stored in TOQentry cell [0] along signal path 586. If the current state of TOQ entrycell [1] indicates an invalid TOQ entry, then the remaining TOQ entrycells 540 recirculate. If, however, TOQ entry cell [1] is marked as avalid TOQ entry, then the TOQ entry is shifted to the next TOQ entrycell 540. In such a case, TOQ entry cell [2] receives the TOQ entrystored in TOQ entry cell [1] along signal path 590. The processcontinues until an invalid (empty) TOQ entry cell 540 is found.

The reserved entry counter 550 analyzes TOQ entry cells 540 marked asvalid and determines a reservation count for each common resource neededby at least one valid TOQ entry. The reservation count for a givenresource is equal to the number of TOQ entry cells 540 marked as validthat require the resource. The reserved entry counter 550 sends thereservation counts to each of the corresponding common resources, suchas the L1 cache memory 460.

The priority selector 560 selects a TOQ entry, associated with a RIB 416in a given SM partition 410, for servicing. Typically, the priorityselector 560 selects the TOQ entry in the rightmost TOQ entry cell 540that is both marked as valid and has reserved all needed resources tocomplete execution. Note that the selected TOQ entry may not necessarilybe stored in the rightmost TOQ entry cell 540 marked as valid. Thus,empty TOQ entry cells 540, or holes, may appear within the middle of agroup of valid TOQ entry cells 540. These holes may be filled as newaccess requests are received from the SM partitions 410. The priorityselector 560 sends RIB read requests and requests to retire RIB entriesto the SM partitions 410.

Note that alternative techniques may be employed to move blocks of TOQentries rather than using a shift register approach as described above.In addition, static information associated with TOQ entries, such asfields not directly related to sleep and wake-up conditions, may bestored within the TOQ entry cells 540, or within a separate memorystructure such as a static memory.

FIGS. 6A and 6B set forth a flow diagram of method steps for addingcommon resource access requests to a total order queue 430, according toone embodiment of the present invention. Although the method steps aredescribed in conjunction with the systems of FIGS. 1-5, persons ofordinary skill in the art will understand that any system configured toperform the method steps, in any order, is within the scope of thepresent invention.

As shown, the method 600 begins at step 602, where the TOQ 430 receivesan access request associated with a common resource. At step 604, theTOQ 430 determines whether the access request is a replay operationrequest. If the access request is not a replay operation request, thenthe access request is a new request, and the method 600 proceeds to step606, where the TOQ 430 increments the reserved counts for each commonresource needed by the access request. At step 608, the TOQ 430determines whether the common resources needed by the access request areavailable for allocation to requests. If the common resources areavailable for allocation, then the method 600 proceeds to step 610,where the TOQ 430 decrements the reserved counts for each commonresource needed by the access request.

At step 612, the TOQ 430 determines whether the access request is readyto complete. The access request is ready to complete if there is noremaining work in order to complete the request, and the request hasbeen accepted by the L1 cache 320. If the access request is ready tocomplete, then the method 600 proceeds to step 614, where the TOQ 430completes the request. The RIB entry corresponding to the TOQ entry isaccessed to complete the request. The RIB entry includes executioninformation associated with the access request that is used forcompleting one or more replay operations. At step 616, the TOQ 430retires the TOQ and RIB entries, if any, associated with the accessrequest. The method 600 then terminates.

Returning now to step 604, if the access request is a replay operationrequest, then the method 600 proceeds to step 622, where the TOQ 430determines whether the TOQ entry associated with the access requestindicates that each needed common resource is either available or haspreviously been reserved. If each needed common resource is eitheravailable or has been reserved, then the method 600 returns to step 610,as described above. If, at step 622, at least one needed common resourceis either unavailable or has not been reserved, then the method 600proceeds to step 624, where the TOQ 430 determines whether the commonresources that are not available or previously reserved can be stolenfrom another access request. If the common resources can be stolen, thenthe method 600 returns to step 610, as described above. If the commonresources cannot stolen, then the method 600 proceeds to step 626, wherethe TOQ 430 reserves common resources that are needed by the accessrequest and available. The TOQ 430 updates the TOQ entry with thisinformation. At step 628, the TOQ 430 puts the TOQ entry to sleep. Themethod 600 then terminates.

Returning now to step 608, if one or more common resources needed by theaccess requires are not available for allocation, then the method 600proceeds to step 630, where the TOQ 430 allocates a TOQ entry to thisaccess request. In such a case, servicing of the access request isdelayed. At step 632, the TOQ 430 determines whether the access requestis missing any long-term resources. If the access request is missing anylong-term resources, then the method 600 returns to step 626, asdescribed above. If the access request is not missing any long-termresources, then the method 600 proceeds to step 634, where the TOQ 430tags the TOQ entry associated with the access request as available forreplay. The method 600 then terminates.

Returning now to step 612, if the access request is not able tocomplete, then the method 600 proceeds to step 618, where the TOQ 430completes one beat of the access request. A beat comprises one or morereplay operations associated with a particular common resource accessrequest. The RIB entry corresponding to the TOQ entry is accessed tocomplete the request. The RIB entry includes execution informationassociated with the access request that is used for completing one ormore replay operations included in the beat. At step 620, the TOQ 430retains the TOQ and RIB entries, if any, associated with the accessrequest. The method 600 then terminates.

Once a TOQ entry is created for an associated common resource accessrequest, the TOQ 430 may update the TOQ entry as the status of commonresources needed by the TOQ entry changes.

FIG. 7 is a flow diagram of method steps for updating the status of acommon resource, according to one embodiment of the present invention.Although the method steps are described in conjunction with the systemsof FIGS. 1-5, persons of ordinary skill in the art will understand thatany system configured to perform the method steps, in any order, iswithin the scope of the present invention.

As shown, the method 700 begins at step 702, where the TOQ 430 receivesan updated status for a common resource needed by one or more TOQentries. At step 704, the TOQ 430 determines whether the status updateindicates that the common resource is available. If the common resourceis not available, then the method 700 terminates.

If, however, the common resource is available the method 700 proceeds tostep 706, where the TOQ 430 calculates the TOQ index for the highestnumbered TOQ entry, where a higher numbered TOQ entry represents anolder access request than a lower numbered TOQ entry. At step 708, theTOQ 430 determines whether the TOQ entry referenced by the index is avalid TOQ entry. The TOQ entry is invalid if the associated accessrequest has completed and the TOQ entry has subsequently been retired.If the TOQ entry is not valid, then the method 700 proceeds to step 710,where the TOQ 430 decrements the index. At step 712, the TOQ 430determines whether the index is greater than or equal to zero. If theindex is not greater than or equal to zero, then the entire TOQ has beenscanned, and the method 700 terminates.

If, at step 712, the index is greater than or equal to zero, then themethod 700 returns to step 708, as described above. If, at step 708, theTOQ entry is valid, then the method 700 proceeds to step 714, where theTOQ 430 determines whether the TOQ entry referenced by the indexrequires the common resource whose status has changed. If the TOQ entrydoes not need the resource, then the method 700 returns to step 710, asdescribed above. If, however, the TOQ entry does need the resource, thenthe method 700 proceeds to step 716, where the TOQ 430 marks theresource as allocated to the TOQ entry associated with the index. Atstep 718, the TOQ 430 determines whether the common resource is stillavailable. If the common resource is still available, then the method700 returns to step 710, as described above. In such a case, the commonresource still is available after the prior allocation, and may still beallocated to additional TOQ entries. If the common resource is no longeravailable, then the method 700 terminates.

As described above in association with FIGS. 6A-6B, TOQ entries may beput to sleep pending availability of one or more needed commonresources. Once the needed common resources become available, the TOQ430 awakens the TOQ entry places the TOQ entry in an active state, sothat the associated access request may continue execution.

FIG. 8 is a flow diagram of method steps for allocating a commonresource to a TOQ entry associated with a common resource accessrequest, according to one embodiment of the present invention. Althoughthe method steps are described in conjunction with the systems of FIGS.1-5, persons of ordinary skill in the art will understand that anysystem configured to perform the method steps, in any order, is withinthe scope of the present invention.

As shown, the method 800 begins at step 802, where the TOQ 430determines whether the TOQ entry associated with a specified index is avalid TOQ entry. The TOQ entry is invalid if the associated accessrequest has completed and the TOQ entry has subsequently been retired.If the TOQ entry is not valid, then the method 800 terminates.

If the TOQ entry is valid, then the method 800 proceeds to step 804,where the TOQ 430 receives an updated status for a common resourceneeded by the TOQ entry. At step 806, the TOQ 430 determines whether thestatus of the common resource is equal to NOT NEEDED, where NOT NEEDEDindicates that the common resource is not needed by the TOQ entry. Insuch a case, no change is needed to the TOQ entry. The method 800proceeds to step 816, where the TOQ 430 determines whether the TOQ entryis waiting for additional resources. If the TOQ entry is not waiting foradditional resources, then the method 800 terminates. If the TOQ entryis waiting for additional resources, then the method 800 returns to step804, as described above.

Returning now to step 806, if the status of the common resource is notequal to NOT NEEDED, then the method 800 proceeds to step 808, where theTOQ 430 determines whether the status of the common resource is equal toNEEDED AND ALLOCATED. A status OF NEEDED AND ALLOCATED indicates thatthe common resource is needed by the TOQ entry, and is already allocatedto the TOQ entry. In such a case, no change is needed to the TOQ entry.The method 800 proceeds to step 816, as described above.

Returning now to step 808, if the status of the common resource is notequal to NEEDED AND ALLOCATED, then the method 800 proceeds to step 810,where the TOQ 430 determines whether the status of the common resourceis equal to SET/WAY IN USE AND LOCKED. A status of SET/WAY IN USE ANDLOCKED indicates that the TOQ entry was put to sleep because the commonresource is needed by the TOQ entry, but the needed set or way of thecommon resource was in use, and the resource was locked. In such a case,the method 800 proceeds to step 818, where the TOQ 430 determineswhether the resource is now unlocked. If the resource is not unlocked,then the method 800 proceeds to step 816, as described above. If theresource is unlocked, then the method 800 proceeds to step 820, wherethe TOQ 430 determines whether the set and way of the common resource isnow available. If the set and way are not available, then the method 800proceeds to step 816, as described above. If the set and way areavailable, then the method 800 proceeds to step 822, where the TOQ 430determines whether the resource is available. If the resource is notavailable, then the method 800 proceeds to step 816, as described above.If the resource is available, then the method 800 proceeds to step 824,where the TOQ 430 sets the status of the resource to NEEDED ANDALLOCATED, indicating the common resource is now allocated to the TOQentry referenced by the index. The method 800 then proceeds to step 816,as described above.

Returning now to step 810, if the status of the common resource is notequal to SET/WAY IN USE AND LOCKED, then the method 800 proceeds to step812, where the TOQ 430 determines whether the status of the commonresource is equal to SET/WAY IN USE. A status of SET/WAY IN USEindicates that the TOQ entry was put to sleep because the commonresource is needed by the TOQ entry, but the needed set or way of thecommon resource was in use. In such a case, the method 800 proceeds tostep 820, as described above, to determine whether the resource and theset and way are now available.

Returning now to step 812, if the status of the common resource is notequal to SET/WAY IN USE, then the method 800 proceeds to step 814, wherethe TOQ 430 determines whether the status of the common resource isequal to NEEDED BUT NOT AVAILABLE. A status of NEEDED BUT NOT AVAILABLEindicates that the TOQ entry was put to sleep because the commonresource is needed by the TOQ, but the resource was not available. Insuch a case, the method 800 proceeds to step 822, as described above, todetermine whether the resource is now available.

Returning now to step 814, if the status of the common resource is notequal to NEEDED BUT NOT AVAILABLE, then the method 800 proceeds to step816, as described above.

Once a TOQ is awake and active, the TOQ 430 may select the TOQ for oneor more replay operations in order that the associated access requestmay resume execution.

FIG. 9 is a flow diagram of method steps for selecting a common resourceaccess request in a total order queue (TOQ) 430 for servicing, accordingto one embodiment of the present invention. Although the method stepsare described in conjunction with the systems of FIGS. 1-5, persons ofordinary skill in the art will understand that any system configured toperform the method steps, in any order, is within the scope of thepresent invention.

As shown, the method 900 begins at step 902, where the TOQ 430initializes an index to point at a first partition within the SM 310. Atstep 904, the TOQ 430 calculates the TOQ index for the highest numberedTOQ entry. At step 906, the TOQ 430 determines whether the TOQ entryreferenced by the TOQ index is a valid TOQ entry and that the partitionreferenced by the partition index is a valid partition. The TOQ entry isinvalid if the associated access request has completed and the TOQ entryhas subsequently been retired. A partition is valid if the partition hasbeen identified to execute the access request associated with the TOQentry. If the TOQ entry or the partition is not valid, then the method900 proceeds to step 908, where the TOQ 430 decrements the index. Atstep 910, the TOQ 430 determines whether the index is greater than orequal to zero. If the index is greater than or equal to zero, then themethod 900 returns to step 908, as described above.

If the index is not greater than or equal to zero, then the entire TOQhas been scanned, and the method 900 proceeds to step 916, where the TOQ430 increments the partition index. At step 918, the TOQ 430 determineswhether the partition index is less than the number of partitions, P. Ifthe partition index is less than P, then the method 900 returns to step904, as described above. If the partition index is not less than P, thenthe entire set of SM partitions has been scanned, and the method 900proceeds to step 920, where the TOQ 430 sends any found replay operationrequests to the respective SM partitions. The method 900 thenterminates.

Returning now to step 906, if the TOQ entry and the partition are bothvalid, then the method 900 proceeds to step 912, where the TOQ 430determines whether each common resource is either not needed by the TOQentry, or the common resource is needed by and has been allocated to theTOQ entry. If not all needed resources have been allocated to the TOQentry, then the method 900 returns to step 908, as described above. Ifall needed resources have been allocated to the TOQ entry, then themethod 900 proceeds to step 914, where the TOQ 430 selects a replayinstruction buffer within the identified partition to execute the accessrequest. The method 900 then proceeds to step 916, as described above.

FIG. 10 is a flow diagram of method steps for aging TOQ entries in a TOQentry buffer 432, according to one embodiment of the present invention.Although the method steps are described in conjunction with the systemsof FIGS. 1-5, persons of ordinary skill in the art will understand thatany system configured to perform the method steps, in any order, iswithin the scope of the present invention.

As shown, the method 1000 begins at step 1002, where the TOQ 430receives a new common resource access request. At step 1004, the TOQ 430creates and stores a TOQ entry corresponding to the access request inthe TOQ entry buffer 432, where the entries in the TOQ buffer are storedin temporal order. Temporal order may be determined in any technicallyfeasible manner including, without limitation, via a priority scheme,least-recently-used, or least-recently-allocated approaches, arrivaltime and position of the common resource access request within the TOQentry buffer 432, or by arrival time and position of a replay operationassociated with the common resource access request within the TOQ entrybuffer 432. The TOQ entry corresponding to the new access request mayoccupy the position in the TOQ entry buffer 432 corresponding to thenewest position in the buffer. Each TOQ entry is shifted one position inthe TOQ entry buffer 432 until an empty position in the TOQ entry buffer432 is found. The empty position is filled with an existing TOQ entry.The empty position may be the oldest valid TOQ entry in the TOQ entrybuffer 432. Alternatively, the empty position may be a “bubble” wherenewer valid TOQ entries existing on one side of the empty position, andolder valid TOQ entries existing on the other side of the emptyposition. In such a case, filling the empty position fills in the“bubble” within the TOQ entry buffer 432.

At step, 1006, the TOQ 430 determines whether a first common resourceneeded by the access request is available for allocation. If the firstcommon resource is not available, then the TOQ waits until the resourcebecomes available. If, at step 1006, the first common resource isavailable, then the method 1000 proceeds to step 1008, where the TOQ 430searches the TOQ entry buffer 432 to identify a subset of TOQ entriesthat correspond to access requests waiting for the first commonresource. At step 1010, the TOQ 430 identifies the TOQ entries withinthe subset of TOQ entries, where all needed common resources, includingthe first common resource, are available.

At step 1012, the TOQ 430 reads the oldest entry in the TOQ entry bufferin the subset of TOQ entries, where all needed common resources,including the first common resource, are available. This TOQ entry mayor may not be the oldest valid TOQ entry in the TOQ entry buffer 432. Atstep 1014, the TOQ 430 causes a RIB entry, corresponding to the TOQentry read in step 1012, to be read into the processing pipeline inorder to execute one or more cycles of the access request. At step 1016,the TOQ 430 determines whether additional cycles are required in orderto complete the access request. If no additional cycles are required,then the method 1000 proceeds to step 1018, where the TOQ 430 retiresthe TOQ entry corresponding to the access request. The TOQ 430 may alsocause the corresponding RIB entry to be retired. If the TOQ entry beingretired is not the last valid request in the TOQ entry buffer 432, thena “hole” or “bubble” may be created within the TOQ entry buffer 432,such that valid TOQ entries exist on both sides of the bubble. Themethod 1000 then terminates.

If, at step 1016, additional cycles are required, then the method 1000proceeds to step 1020, where the TOQ 430 retains the TOQ entrycorresponding to the access request. The TOQ 430 may also cause thecorresponding RIB entry to be retained. The method 1000 then terminates.

FIG. 11 is a flow diagram of method steps for transitioning a TOQ entryassociated with a common resource access request from a sleep state toan active state, according to one embodiment of the present invention.Although the method steps are described in conjunction with the systemsof FIGS. 1-5, persons of ordinary skill in the art will understand thatany system configured to perform the method steps, in any order, iswithin the scope of the present invention.

As shown, the method 1100 begins at step 1102, where the TOQ 430determines that a common resource is now available for allocation toaccess requests. At step 1104, the TOQ 430 determines whether a TOQentry within the TOQ entry buffer 432 is in a sleep state, where awake-up condition of the TOQ entry is satisfied when the common resourceis available. If no TOQ entry is waiting for the common resource, thenthe method 1100 terminates.

If at step 1104, one or more TOQ entries are waiting for the commonresource, the method proceeds to step 1106, where the TOQ 430 issues awake-up operation. The wake-up operation may be issued as a singlewake-up operation to a specific TOQ entry. Alternatively, the wake-upoperation may be broadcast to multiple TOQ entries that are waiting forthe common resource. At step 1108, the TOQ 430 determines whether theTOQ entry receiving the wake-up in step 1106 is waiting for other commonresources that remain unavailable. If the TOQ entry is not waiting forother unavailable resources, then the method 1100 proceeds to step 1110,where the TOQ 430 allows one or more cycles of the access request toexecute. The method 1100 then terminates.

If, at step 1108, the TOQ entry is waiting for other unavailableresources, then the method 1100 proceeds to step 1112, where the TOQ 430determines whether the unavailable resources are unavailable on ashort-term or transient basis. If the resources are unavailable for ashort term, then the method 1100 proceeds to step 1110, as above. If theresources are unavailable for a long term, then the method 1100 proceedsto step 1114, where the TOQ 430 determines whether the unavailableresources may be stolen from another TOQ entry. If the unavailableresources may not be stolen, then the method proceeds to step 1116,where the TOQ 430, places the TOQ entry back into a sleep state. Themethod 1100 then terminates.

If, at step 1114, the unavailable resources may be stolen, then themethod 1100 proceeds to step 1118, where the TOQ 430 steals theunavailable resources from other TOQ entries. The TOQ 430 may steal theresource via physical stealing or virtual stealing as described above inconjunction with FIG. 4. In one example, the unavailable resources maybe stolen only after a predetermined amount of time has elapsed. Inanother example, only the oldest valid TOQ entry may be eligible tosteal resources from other TOQ entries. The method 1100 then proceeds tostep 1110, as above.

It should be appreciated that the architecture described herein isillustrative only and that variations and modifications are possible.For example, the architecture described herein is presented in thecontext of a load-store unit 303 of a streaming multiprocessor 310, butmay be employed in any processing unit that accesses common resources,including, without limitation, in association with a central processingunit (CPU), general processing unit (GPU), or in any other technicallyfeasible compute environment. In yet another example, each RIB 416 neednot have an identical number of entries, so long at the TOQ 430 isconfigured to track the entries within each RIB 416. In another example,the techniques are described within the context of multiple SMpartitions 410 and other clients competing for a common execution unit.However, other configurations are supported within the context of thedisclosed techniques, including, without limitation, a single clientaccessing multiple execution units or multiple clients accessingmultiple execution units. The various clients may be serviced in anytechnically feasible manner, including, without limitation, a rotatingtime slice order, priority-based approaches, or dynamic loading. In yetanother example, the disclosed TOQ 430 is described in the context of acentralized control unit servicing multiple SM partitions 410 and otherrequest sources for a common execution unit. Alternatively,decentralized control may be employed where each SM partition 410 andclient may manage a separate sub-TOQ, where the age of each request isrelative to each sub-TOQ. In such a case, a global aging mechanism maybe employed for selective wakeup operations.

The techniques described herein are described with respect to commonresource access operations, such as load and store access requestsacross multiple threads where the threads access memory locations acrossdivergent cache lines. The techniques are sufficiently flexible to beemployed in other applications where common resource access requests arepresent. In one example, the techniques described herein are not limitedto execution of threads, but may be employed for any operations whichmay proceed via multiple functional processing units that access commonresources. In another example, an instruction may diverge across acommon resource other than cache lines within a cache. Such resourcesmay include, without limitation, cache tags, cache data, register banks,and shared memory. The threads executing the common resource accessrequest may access different aspects or portions of the common resource,such as different sets within a cache memory or different ways within acache set. In yet another example, the LSU 303 may retrieve multiplecommon resources, such as multiple cache lines, during any givenoperation. In yet another example, a given common resource may have morethan one simultaneous access port, where access is denied when allavailable access ports are consumed by other requestors.

Persons of ordinary skill in the art will appreciate that the commonresource configurations described herein are illustrative only and thatvariations and modifications are possible. For example, although somecommon resources are described herein as having a set and a way, as istypical in a set-associative cache, other common resource configurationscould be employed in the context of the described techniques, including,without limitation, direct mapped caches (typically having one way perset), fully associative caches (typically having one set), and sectoredcaches, in any combination. In a sectored cache, a cache line, asrepresented by a set and a way, could be further sub-divided intosectors. In such a configuration, the TOQ 430 could track commonresource usage by sector in addition to tracking by set and way. Inanother example, various cache line replacement policies could beemployed, including, without limitation, least recently used (LRU) andleast recently allocated (LRA) approaches.

In sum, the disclosed technique provides an optimized way to maintainfairness and order in the scheduling of common resource access requestsrelated to replay operations. Specifically, a streaming multiprocessor(SM) 310 includes a total order queue (TOQ) 430 configured to schedulethe access requests over one or more replay operations for accessrequest that do not complete in a single execution cycle. If all commonresources have been allocated to the access request or are otherwiseavailable, then the access request is allowed to execute one or morereplay operations. If the access request is waiting for at least onelong-term resource, the TOQ 430 places the access request in a sleepstate pending availability of the resource. The TOQ entry associatedwith the access request is placed in an awake state when a neededresource becomes available. Priority is given to access requestsaccording to the age of the access request and the status of commonresources. When two or more access requests are deadlocked waiting forthe same resources, the TOQ may allow the older access request to stealresources from the younger resource request, such that each accessrequest is able to complete execution.

Advantageously, older common resource access requests are not repeatedlyblocked from making forward progress by newer access requests. Priorityinversions are avoided by allocating the common resource to an existingolder access request in preference to the new access request. Theresources of the SM 310 are utilized more efficiently because accessrequests in the sleep state do not actively compete for commonresources. Additionally, deadlock and livelock is avoided by allowing anolder TOQ entry to steal resources allocated to a younger entry, suchthat the access request associated with the older entry is able tocomplete execution, followed by the access request associated with theyounger entry. Further, fairness and order in scheduling access requestsis maintained even as the set of common resources needed changes duringexecution.

While the foregoing is directed to embodiments of the present invention,other and further embodiments of the invention may be devised withoutdeparting from the basic scope thereof, and the scope thereof isdetermined by the claims that follow.

What is claimed is:
 1. A method for managing requests for commonresources in a processing pipeline, the method comprising: receiving afirst request for a first common resource; determining that the firstcommon resource is not available for allocation to requests; inresponse, delaying servicing the first request; subsequent to delayingservicing, receiving a second request for the first common resource;subsequent to receiving the second request, determining that the firstcommon resource has become available for allocation to requests; andmaking the first common resource available to the first request, priorto making the first common resource available to the second request. 2.The method of claim 1, further comprising creating a first entry in afirst buffer for the first request to track the age of the firstrequest, wherein the first entry indicates that the first request isassociated with at least the first common resource.
 3. The method ofclaim 2, further comprising, upon receiving the second request,searching the first buffer for any entry corresponding to a request thatis associated with the first common resource.
 4. The method of claim 3,further comprising identifying via the first entry that the firstrequest is associated with the first common resource, and, in response,determining that the first request should be serviced prior to thesecond request.
 5. The method of claim 2, further comprising creating asecond entry in the first buffer for the second request to track the ageof the second request, wherein the second entry indicates that thesecond request is associated with at least the first common resource. 6.The method of claim 5, upon determining that the first common resourceis available, searching the first buffer for any entry corresponding toa request that is associated with the first common resource.
 7. Themethod of claim 6, further comprising identifying via the first entryand the second entry that the first request and the second request areassociated with the first common resource and that the first request isolder than the second request, and, in response, determining that thefirst request should be serviced prior to the second request.
 8. Themethod of claim 2, further comprising causing a first entry to becreated in a replay buffer that corresponds to the first entry in thefirst buffer, wherein the first entry in the replay buffer includesexecution information associated with the first request that is used forreplay operations associated with the first request.
 9. The method ofclaim 2, wherein the first entry further includes information thatindicates the status of the first common resource.
 10. The method ofclaim 9, wherein the status of the first common resource is that thefirst common resource is needed by the first request but not allocatedto the first request or that the first common resource is locked andunavailable to the first request.
 11. A subsystem for managing requestsfor common resources in a processing pipeline, comprising: a total orderqueue (TOQ) configured to perform the steps of: receiving a firstrequest for a first common resource; determining that the first commonresource is not available for allocation to requests; in response,delaying servicing the first request; subsequent to delaying servicing,receiving a second request for the first common resource; subsequent toreceiving the second request, determining that the first common resourcehas become available for allocation to requests; and making the firstcommon resource available to the first request, prior to making thefirst common resource available to the second request.
 12. The subsystemof claim 11, wherein the TOQ is further configured to perform the stepof creating a first entry in a first buffer for the first request totrack the age of the first request, wherein the first entry indicatesthat the first request is associated with at least the first commonresource.
 13. The subsystem of claim 12, wherein the TOQ is furtherconfigured to perform the step of, upon receiving the second request,searching the first buffer for any entry corresponding to a request thatis associated with the first common resource.
 14. The subsystem of claim13, wherein the TOQ is further configured to perform the steps ofidentifying via the first entry that the first request is associatedwith the first common resource, and, in response, determining that thefirst request should be serviced prior to the second request.
 15. Thesubsystem of claim 12, wherein the TOQ is further configured to performthe step of creating a second entry in the first buffer for the secondrequest to track the age of the second request, wherein the second entryindicates that the second request is associated with at least the firstcommon resource.
 16. The subsystem of claim 15, wherein the TOQ isfurther configured to perform the step of, upon determining that thefirst common resource is available, searching the first buffer for anyentry corresponding to a request that is associated with the firstcommon resource.
 17. The subsystem of claim 16, wherein the TOQ isfurther configured to perform the steps of identifying via the firstentry and the second entry that the first request and the second requestare associated with the first common resource and that the first requestis older than the second request, and, in response, determining that thefirst request should be serviced prior to the second request.
 18. Thesubsystem of claim 12, wherein the TOQ is further configured to performthe step of causing a first entry to be created in a replay buffer thatcorresponds to the first entry in the first buffer, wherein the firstentry in the replay buffer includes execution information associatedwith the first request that is used for replay operations associatedwith the first request.
 19. The subsystem of claim 12, wherein the firstentry further includes information that indicates the status of thefirst common resource, and the status of the first common resource isthat the first common resource is needed by the first request but notallocated to the first request or that the first common resource islocked and unavailable to the first request.
 20. A computing device,comprising: a total order queue (TOQ) configured to manage requests forcommon resources in a processing pipeline by performing the steps of:receiving a first request for a first common resource; determining thatthe first common resource is not available for allocation to requests;in response, delaying servicing the first request; subsequent todelaying servicing, receiving a second request for the first commonresource; subsequent to receiving the second request, determining thatthe first common resource has become available for allocation torequests; and making the first common resource available to the firstrequest, prior to making the first common resource available to thesecond request.